package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.core.domain.entity.SysDept;
import com.blrs.domain.vo.QuotationProductMessageVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.QuotationInfo;
import com.blrs.service.enterprise.quotation.IQuotationInfoService;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2023-09-25
 */
@RestController
@RequestMapping("/quotation/info")
public class QuotationInfoController extends BaseController
{
    @Autowired
    private IQuotationInfoService quotationInfoService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuotationInfo quotationInfo)
    {
        startPage();
        List<QuotationInfo> list = quotationInfoService.selectQuotationInfoList(quotationInfo);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QuotationInfo quotationInfo)
    {
        List<QuotationInfo> list = quotationInfoService.selectQuotationInfoList(quotationInfo);
        ExcelUtil<QuotationInfo> util = new ExcelUtil<QuotationInfo>(QuotationInfo.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{quotationId}")
    public AjaxResult getInfo(@PathVariable("quotationId") String quotationId)
    {
        return success(quotationInfoService.selectQuotationInfoByQuotationId(quotationId));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuotationInfo quotationInfo)
    {
        return toAjax(quotationInfoService.insertQuotationInfo(quotationInfo));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuotationInfo quotationInfo)
    {
        return toAjax(quotationInfoService.updateQuotationInfo(quotationInfo));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quotationIds}")
    public AjaxResult remove(@PathVariable String[] quotationIds)
    {
        return toAjax(quotationInfoService.deleteQuotationInfoByQuotationIds(quotationIds));
    }

    @PostMapping("/saveQuotationProductMessage")
    public AjaxResult saveQuotationProductMessage(@RequestBody QuotationProductMessageVo quotationProductMessageVo) {
        return toAjax(quotationInfoService.saveQuotationProductMessage(quotationProductMessageVo));
    }

    @PostMapping("/updateQuotationProductMessage")
    public AjaxResult updateQuotationProductMessage(@RequestBody QuotationProductMessageVo quotationProductMessageVo) {
        return toAjax(quotationInfoService.updateQuotationProductMessage(quotationProductMessageVo));
    }

    @GetMapping("/sysDeptInfo")
    public List<SysDept> sysDeptInfo(SysDept sysDept)
    {
        return quotationInfoService.selectDeptInfoByUserId(sysDept);
    }

}
